package com.inwil.bms.service.term.impl;

import com.google.gson.Gson;
import com.inwil.bms.dao.shop.model.ShopGoodsInfoVO;
import com.inwil.bms.dao.term.model.ReportVO;
import com.inwil.bms.dao.term.model.TermPaperPageTemplateVO;
import com.inwil.bms.dao.term.model.TermTemplateConfigBean;
import com.inwil.bms.dao.term.model.TermThemeVO;
import com.inwil.bms.enums.TermPageTemplateStatus;
import com.inwil.bms.enums.TermPageTemplateTypeEnum;
import com.inwil.bms.service.term.TermThemeService;
import com.inwil.bms.util.common.Validator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


@RunWith(SpringRunner.class)
@SpringBootTest


public class TermPaperTemplateServiceImplTest {

    private static final Logger logger = LoggerFactory.getLogger(TermPaperTemplateServiceImplTest.class);

    private static final String DIR = "D:\\INWIL\\coding\\学期报\\paperTemplate\\二期\\";
    private static final Integer VERSION = 1;


    @Autowired
    private TermPaperPageTemplateServiceImpl termPaperPageTemplateService;


    @Autowired
    private TermThemeService termThemeService;


    @Test
    public void templateEnum() {
        TermPageTemplateTypeEnum[] values = TermPageTemplateTypeEnum.values();

        Set<String> templateSet = new HashSet<>();

        for (TermPageTemplateTypeEnum termPageTemplateTypeEnum : values) {
            logger.info("type = {}, name = {}", termPageTemplateTypeEnum.getType(), termPageTemplateTypeEnum.getCode());

            templateSet.add(termPageTemplateTypeEnum.getCode());
        }

        System.out.println("一共多个模板： " + values.length);
        System.out.println("templateSet.size() = " + templateSet.size() + ", 模板类型: " + templateSet);
    }


    public String getTemplateConfig(String fileName) throws Exception {
        if (Validator.empty(fileName)) {
            return null;
        }

        String filePath = DIR + fileName;

        String s = fileRead(filePath);
        String replaceStr = s.replaceAll("\\s*", "");

        return replaceStr;
    }


    public String fileRead(String filePath) throws Exception {
        File file = new File(filePath);//定义一个file对象，用来初始化FileReader
        FileReader reader = new FileReader(file);//定义一个fileReader对象，用来初始化BufferedReader
        BufferedReader bReader = new BufferedReader(reader);//new一个BufferedReader对象，将文件内容读取到缓存
        StringBuilder sb = new StringBuilder();//定义一个字符串缓存，将字符串存放缓存中
        String s = "";

        while ((s = bReader.readLine()) != null) {//逐行读取文件内容，不读取换行符和末尾的空格
            sb.append(s + "\n");//将读取的字符串添加换行符后累加存放在缓存中
        }
        bReader.close();

        return sb.toString();
    }


    private TermPaperPageTemplateVO createTemplateVO(TermTemplateConfigBean termTemplateConfigBean,
                                                     String templateConfig,
                                                     TermPageTemplateTypeEnum templateTypeEnum) {

        TermPaperPageTemplateVO templateVO = new TermPaperPageTemplateVO();

        if (termTemplateConfigBean == null) {

            termTemplateConfigBean = new TermTemplateConfigBean();
            termTemplateConfigBean.setName(templateTypeEnum.getCode());
            templateConfig = "{\"name\":\"" + templateTypeEnum.getCode() + "\"}";
        }


        BeanUtils.copyProperties(termTemplateConfigBean, templateVO);
        System.out.println(templateVO);

        // 模版背景图
        if (!Validator.empty(termTemplateConfigBean.getBackgroundImage())) {
            templateVO.setBgImg(termTemplateConfigBean.getBackgroundImage());
        }

        // 是否允许添加使用模板
        // if (!Validator.empty(termTemplateConfigBean.getCanSort())) {
        //     templateVO.setCanAdd(termTemplateConfigBean.getCanSort());
        // }


        // 是否允许能拖拽排序
        if (!Validator.empty(termTemplateConfigBean.getCanSort())) {
            templateVO.setCanSort(termTemplateConfigBean.getCanSort());
        }


        // 是否允许能编辑
        if (!Validator.empty(termTemplateConfigBean.getCanEdit())) {
            templateVO.setCanEdit(termTemplateConfigBean.getCanEdit());
        }

        // 配置
        templateVO.setConfig(templateConfig);

        templateVO.setType(templateTypeEnum.getType());

        templateVO.setCode(templateTypeEnum.getCode());

        templateVO.setSortOrder(templateTypeEnum.getSortOrder().longValue());
        templateVO.setVersion(VERSION);

        // 模板名称
        if (!Validator.empty(termTemplateConfigBean.getName())) {
            templateVO.setName(termTemplateConfigBean.getName());
        }


        return templateVO;
    }

    
    


    /**
     * 获取模板VO
     *
     * @param fileName
     * @param templateTypeEnum
     * @return
     * @throws Exception
     */
    private TermPaperPageTemplateVO getTemplateVO(String fileName, TermPageTemplateTypeEnum templateTypeEnum) throws Exception {

        TermTemplateConfigBean termTemplateConfigBean = null;
        String templateConfig = "";

        if (!Validator.empty(fileName)) {

            templateConfig = getTemplateConfig(fileName);
            System.err.println(templateConfig);

            termTemplateConfigBean = new Gson().fromJson(templateConfig, TermTemplateConfigBean.class);

            System.out.println(termTemplateConfigBean);

        }

        Long themId = null;

        if (themId == null) {
            // 第二期 学期报
            TermThemeVO currentTheme = termThemeService.getCurrentTheme();
            themId = currentTheme.getId();
        }

        TermPaperPageTemplateVO templateVO = termPaperPageTemplateService.getTempalteByType(themId, templateTypeEnum.getType());

        if (templateVO != null) {
            logger.info("code1 = {}, type2 ={},  code2= {}, type2 = {} ", templateVO.getCode(),
                    templateVO.getType(), templateTypeEnum.getCode(), templateTypeEnum.getCode());
        }

        TermPaperPageTemplateVO createTemplateVO = createTemplateVO(termTemplateConfigBean, templateConfig, templateTypeEnum);
        if (templateVO != null) {
            createTemplateVO.setId(templateVO.getId());
        }
        createTemplateVO.setThemeId(themId);


        return createTemplateVO;
    }




    /**
     * 1 生成封面数据 studentVO, termInfoVO
     */
    @Test
    public void generateCoverPage() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COVER;


        String fileName = "01 term_cover.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 2 生成幼儿档案介绍页 数据 studentVO
     */
    @Test
    public void generateStudentPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.STUDENT_INFO;


        String fileName = "02 personal_profile.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 生成学期报 目录页面
     */
    @Test
    public void generateCatalogPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CATALOG;


        String fileName = "";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 第一部分封皮
     */
    @Test
    public void generateFirstCover() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.FIRST_COVER;


        String fileName = "03 first_port_cover.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 五大领域 全面发展 雷达图
     */
    @Test
    public void generateDomainRadar() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ASS_DOMAIN_RADAR;


        String fileName = "04 development_radar.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 五大领域 全面发展 文字表格
     */
    @Test
    public void generateDomainText() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ASS_DOMAIN_TEXT;


        String fileName = "05 development_list.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 最具有优势的几大能力
     */
    @Test
    public void generateTopAbility() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ASS_ABILITY_TOPN;


        String fileName = "06 advatage_ability.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 需要提高的几大能力
     */
    @Test
    public void generateLastAbility() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ASS_ABILITY_LASTN;


        String fileName = "07 developing_ability.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 本学期具有进步的行为
     */
    @Test
    public void generateUpBehavior() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ASS_UP_BEHAVIOR;


        String fileName = "08 improved_behavior.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 第二部分封皮
     */
    @Test
    public void generateSecondCover() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.SECOND_COVER;


        String fileName = "09 second_port_cover.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 观察记录横模板
     */
    @Test
    public void generateCorHorizontalPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL;


        String fileName = "10 h_record_1.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        // templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.NO.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }

    /**
     * 观察记录横模板
     */
    @Test
    public void generateCorHorizontalPage2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL2;


        String fileName = "10 h_record_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorVerticalPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL;


        String fileName = "11 v_record_1.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }

    @Test
    public void generateCorVerticalPage2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL2;


        String fileName = "11 v_record_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorSquarePage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE;


        String fileName = "12 s_record_1.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorSquarePage2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE2;


        String fileName = "12 s_record_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    // +++++++++++++++++++++++++++++++++++++++++++ 140 ~ 300字模板  start  ++++++++++++++++++++++++++++++++++++++++++++++++++


    /**
     * 观察记录横模板
     */
    @Test
    public void generateCorHorizontalMaxWordPageV1() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL_MAX_WORD_V2;


        String fileName = "10 h_record_long.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorVerticalMaxWordPageV1() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL_MAX_WORD_V2;


        String fileName = "11 v_record_long.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());

        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorSquareMaxWordPageV1() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE_MAX_WORD_V2;


        String fileName = "12 s_record_long.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }
    // +++++++++++++++++++++++++++++++++++++++++++ 140 ~ 300字模板  end  ++++++++++++++++++++++++++++++++++++++++++++++++++


    // +++++++++++++++++++++++++++++++++++++++++++ 无字模板 start  ++++++++++++++++++++++++++++++++++++++++++++++++++

    /**
     * 观察记录横模板
     */
    @Test
    public void generateCorHorizontalMaxWordPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL_MAX_WORD;


        String fileName = "10 h_record_empty.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }

    @Test
    public void generateCorHorizontalMaxWordPage2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL_MAX_WORD2;


        String fileName = "10 h_record_empty_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorHorizontalMaxWordPage3() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL_MAX_WORD3;


        String fileName = "10 h_record_empty_3.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorVerticalMaxWordPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL_MAX_WORD;


        String fileName = "11 v_record_empty.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());

        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorVerticalMaxWordPage2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL_MAX_WORD2;


        String fileName = "11 v_record_empty_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());

        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorVerticalMaxWordPage3() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL_MAX_WORD3;


        String fileName = "11 v_record_empty_3.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());

        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorSquareMaxWordPage() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE_MAX_WORD;


        String fileName = "12 s_record_empty.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorSquareMaxWordPage2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE_MAX_WORD2;


        String fileName = "12 s_record_empty_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    @Test
    public void generateCorSquareMaxWordPage3() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE_MAX_WORD3;


        String fileName = "12 s_record_empty_3.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    // +++++++++++++++++++++++++++++++++++++++++++ 无字模板  end  ++++++++++++++++++++++++++++++++++++++++++++++++++

    /**
     * 自定义页面  主题教学
     */
    @Test
    public void generateCustomThemTeach() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_THEM_TEACH;

        String fileName = "15 ThematicTeaching.json";
        fileName = "15 thematic_teaching.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 自定义页面  园所活动
     */
    @Test
    public void generateCustomSchoolAct() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_SCHOOL_ACT;

        String fileName = "16 GardenActivity.json";
        fileName = "16 garden_activity.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 自定义页面  风采展示
     */
    @Test
    public void generateCustomElegantShow() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_ELEGANT_SHOW;

        String fileName = "17 StyleDisplay.json";
        fileName = "17 style_display.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 自定义页面  作品展示
     */
    @Test
    public void generateCustomWorksShow() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_WORKS_SHOW;

        String fileName = "18 WorksDisplay.json";
        fileName = "18 works_display.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 自定义页面  我的伙伴
     */
    @Test
    public void generateCustomMyPartner() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_MY_PARTNER;

        String fileName = "19 MyPartner.json";
        fileName = "19 my_partner.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 自定义页面  我和老师
     */
    @Test
    public void generateCustomTeacherAndMe() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_TEACHER_AND_ME;

        String fileName = "20 MyTeacherAndI.json";
        fileName = "20 teacher_and_i.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 自定义页面  爱的全家福
     */
    @Test
    public void generateCustomFamily() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.CUSTOM_FAMILY;

        String fileName = "21 LovesFamily.json";
        fileName = "21 loves_family.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);

        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanAdd(TermPageTemplateStatus.TemplateAdd.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 第三部分封皮
     */
    @Test
    public void generateThirdCover() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.THIRD_COVER;


        String fileName = "13 third_cover.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 关于机构
     */
    @Test
    public void generateAboutOrg() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ABOUT_ORG;


        String fileName = "26 about_org.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 机构 核心理念
     */
    @Test
    public void generateOrgCoreIdea() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ORG_CORE_IDEA;


        String fileName = "27 core_idea.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 机构 幸福教育
     */
    @Test
    public void generateOrgHappyEdu() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ORG_HAPPY_EDU;


        String fileName = "28 happy_education.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 关于园所
     */
    @Test
    public void generateAboutSchool() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.ABOUT_SCHOOL;

        String fileName = "29 about_school.txt";

        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    /**
     * 封底
     */
    @Test
    public void generateBackCover() throws Exception {
        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.BACK_COVER;


        String fileName = "30 back_cover.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }


    // 超多换行的的模板



    @Test
    public void generateCorVerticalMulline() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL_MULLINE;


        String fileName = "11 v_record_mulline_1.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }

    @Test
    public void generateCorVerticalMulline2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_VERTICAL_MULLINE2;


        String fileName = "11 v_record_mulline_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }



    @Test
    public void generateCorSquareMulline() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE_MULLINE;


        String fileName = "12 s_record_mulline_1.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }

    @Test
    public void generateCorSquareMulline2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_SQUARE_MULLINE2;


        String fileName = "12 s_record_mulline_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }




    @Test
    public void generateCorHorizontalMulline() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL_MULLINE;


        String fileName = "10 h_record_mulline_1.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }

    @Test
    public void generateCorHorizontalMulline2() throws Exception {

        TermPageTemplateTypeEnum templateTypeEnum = TermPageTemplateTypeEnum.COR_HORIZONTAL_MULLINE2;


        String fileName = "10 h_record_mulline_2.txt";


        TermPaperPageTemplateVO templateVO = getTemplateVO(fileName, templateTypeEnum);
        templateVO.setCanSort(TermPageTemplateStatus.TemplateSort.YES.getCode());
        templateVO.setCanEdit(TermPageTemplateStatus.TemplateEdit.YES.getCode());
        templateVO.setCanDelete(TermPageTemplateStatus.TemplateDel.YES.getCode());


        termPaperPageTemplateService.saveOrUpdate(templateVO);
    }



}